<?php
namespace app\admin\model;
use think\Model;

class OrderPayment extends Model
{

    /**
     * 获取认投账户详情列表
     * @param $condition 条件
     * @param $field 查询字段
     * @param $page_size 分页数据
     * @param $page_size 排序
     * @author hey_heyang
     * @return  array()
     */

    public function getTotalListData($condition1,$condition2,$field1,$field2,$page_size=10,$sort='DESC'){
        $order_model =new Order();
        $data_sql1 = $order_model->alias('o')->join('member m','m.id=o.uid')->join('project p','p.id=o.project_id')->where($condition1)->field($field1)->buildSql();
        $data2 = $this->alias('op')->join('member m','m.mobile=op.mobile')->join('project p','p.id=op.project_id')->where($condition2)->field($field2)->union([$data_sql1])->buildSql();
        $data = $this->table($data2 . ' a')->order('time '.$sort)->paginate($page_size,false,page_param());
        return $data;

    }


    /**
     * 获取导出的excel数据
     * @param $condition 条件
     * @param $field 查询字段
     * @param $page_size分页数据
     * @param $page_size_size 排序
     * @author hey_heyang
     * @return  array()
     */
    public function getExcelTotalListData($condition1,$condition2,$field1,$field2,$page_size=10,$sort='DESC'){
        $order_model =new Order();
        $data_sql1 = $order_model->alias('o')->join('member m','m.id=o.uid')->join('project p','p.id=o.project_id')->where($condition1)->field($field1)->buildSql();
        $data = $this->alias('op')->join('member m','m.mobile=op.mobile')->join('project p','p.id=op.project_id')->where($condition2)->field($field2)->union([$data_sql1])->buildSql();
        $data = $this->table($data . ' a')->order('time '.$sort)->select()->toArray();
        return $data;

    }





    /**
     * 获取认投账户代付详情
     * @param $condition 条件
     * @param $field 查询字段
     * @param $page_size 分页数据
     * @param $page_size 排序
     * @author hey_heyang
     * @return  array()
     */

    public function getOpMoneyData($condition,$field,$page_size=10,$sort='ASC'){
        $data = $this->alias('op')->join('member m','m.mobile=op.mobile')->join('project p','p.id=op.project_id')->where($condition)->field($field)->order('op.payment_time'.$sort)->paginate($page_size);
        return $data;

    }

    /**
     * 获取认投账户代付详情
     * @param $condition 条件
     * @param $field 查询字段
     * @author hey_heyang
     * @return  array()
     */

    public function getOpMoneyDataToArray($condition,$field){
        $data = $this->alias('op')->join('member m','m.mobile=op.mobile')->join('project p','p.id=op.project_id')->where($condition)->field($field)->select()->toArray();
        return $data;

    }
	
}